-
Notifications
You must be signed in to change notification settings - Fork 27
How do I use JSON with Minizinc? #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The original
|
Could I do the same thing via the Python interface somehow? I tried the following amongst others and it failed with the same error. from enum import Enum
from minizinc import Instance, Model, Solver
# Load the model
model = Model('/home/mrakgr/inference-servers/icf/prototype.mzn')
# Create a solver instance
gecode = Solver.lookup('gecode')
instance = Instance(gecode, model)
models = Enum("MODELS", ["LLAMA4_SMALL_ON_OPENROUTER", "LLAMA4_MEDIUM_ON_S19", "SOME_NEW_LARGE_MODEL_ON_UNKNOWN_MARKETPLACE"])
machines = Enum("MACHINES", ["M1", "M2", "M3"])
types = Enum("TYPES", ["HGX"])
data = {
"MODELS": models,
"MACHINES": machines,
"TYPES": types,
"gpus_per_model": [1, 1, 1],
"machines": [
{"gpus": 8, "machine_type": "HGX", "cost_per_gpu": 0.0001},
{"gpus": 8, "machine_type": "HGX", "cost_per_gpu": 0.0001},
{"gpus": 8, "machine_type": "HGX", "cost_per_gpu": 0.0001}
],
"workload_per_type_per_model": [[3.0, 2.0, 1.0]],
"predictions": [
{"model": "LLAMA4_SMALL_ON_OPENROUTER", "price": 10, "workload": 10},
{"model": "LLAMA4_MEDIUM_ON_S19", "price": 10, "workload": 10},
{"model": "SOME_NEW_LARGE_MODEL_ON_UNKNOWN_MARKETPLACE", "price": 10, "workload": 10}
]
}
for k,v in data.items():
instance[k] = v
# Solve the instance
result = instance.solve()
# Print the result
print(result)
# python run.py
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have no idea how to use enum fields in non-
.dzn
files. When I try to runminizinc prototype.mzn prototype.json
I get theError: type error: initialisation value for
predictions' has invalid type-inst: expectedarray[_] of record(MODELS: model, float: price, float: workload)', actual
array[_] of record(string: model, int: price, int: workload)'`. Here is the file:The text was updated successfully, but these errors were encountered: